<?php

/**
 * Question form.
 *
 * @package    tests
 * @subpackage form
 * @author     Djul
 */
class QuestionForm extends BaseQuestionForm
{
  public function configure()
  {
      $c = new Criteria();
      if(!sfContext::getInstance()->getUser()->getGuardUser()->getIsSuperAdmin())
      {
        $c->addJoin(TestPeer::TEST_BLOCK_ID, TestBlockPeer::ID);
        $c->addJoin(TestBlockPeer::SUBJECT_ID, UserSubjectPeer::SUBJECT_ID);
        $c->addJoin(UserSubjectPeer::USER_ID, sfContext::getInstance()->getUser()->getGuardUser()->getId());
      }

      $this->widgetSchema['question'] = new isicsWidgetFormTinyMCE(array('tiny_options' => array(
        'width'=>600,
        'height'=>350,
        'skin'=>'o2k7',
        'dialog_type' => 'modal',
        'relative_urls'=> false,
	'plugins' => 'pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template',
	'theme_advanced_buttons1' => 'save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect',
        'theme_advanced_buttons1_add' => 'spellchecker,|,tinybrowser',
	'theme_advanced_buttons2' => 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|preview',
	'theme_advanced_buttons3' => 'tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,fullscreen',
	'theme_advanced_toolbar_location' => 'top',
	'theme_advanced_toolbar_align' => 'left',
	'theme_advanced_statusbar_location' => 'none',
	'theme_advanced_resizing' => true,
	'paste_auto_cleanup_on_paste' => true,
        'theme'  => 'advanced',
        'file_browser_callback' => "tinyBrowser"
      )));
      // 

      $this->widgetSchema['test_id'] = new sfWidgetFormPropelChoice(array('model' => 'Test', 'add_empty' => false, 'criteria'=>$c));
      $this->validatorSchema['test_id'] = new sfValidatorPropelChoice(array('model' => 'Test', 'column' => 'id','criteria'=>$c));

      $this->widgetSchema['level'] = new sfWidgetFormChoice(array('choices'=>array(1 => 1, 2 => 2, 3 => 3)));
      
      $this->validatorSchema->setOption('allow_extra_fields', true);
      $this->validatorSchema->setOption('filter_extra_fields', false);
      $js_path = '/js/tiny_mce/tiny_mce.js';
      sfContext::getInstance()->getResponse()->addJavascript($js_path);
  }
}
